package svc

import (
	"jgt-oper/src/bll"
	"jgt-oper/src/context"
	"jgt-oper/src/schema"
)

// User 用户管理
type User struct {
	UserBll     *bll.User     `inject:""`
	UserTypeBll *bll.UserType `inject:""`
}

// Get 获取用户信息
func (a *User) Get(ctx *context.Context) error {
	item, err := a.UserBll.Get(ctx.Param("id"))
	if err != nil {
		return ctx.ResErrInternalServer(err)
	}
	return ctx.ResSuccess(item)
}

// QueryTypes 查询用户类型列表
func (a *User) QueryTypes(ctx *context.Context) error {
	ps := new(schema.UserTypeQueryParam)
	ps.Status = 1
	data, err := a.UserTypeBll.QueryAll(*ps)
	if err != nil {
		return ctx.ResErrInternalServer(err)
	}
	return ctx.ResSuccess(data)
}
